//    Copyright (C) Kherty.  All rights reserved.
using System;
using OpenLS.Chart;
using OpenLS.Core.Serialization;

namespace OpenLS.Spreadsheet
{
    public class XmlColumnProperties: IOfficeXmlSerializable
    {
        private ExtensionList _extLst;
        private int _mapId;
        private string _xpath;
        private bool _denormalized;
        private XmlDataType _xmlDataType; 

        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (var c = context.Read("xmlColumnPr"))
            {
                _mapId = c.GetUIntegerAsInteger("mapId");
                _xpath = c.GetString("xpath");
                _denormalized = c.GetOptionalBoolean("denormalized", false);
                _xmlDataType = c.GetEnum<XmlDataType>("xmlDataType");
                _extLst = c.ReadOptionalElement<ExtensionList>("extLst");
            }

        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (var c = context.Write("xmlColumnPr"))
            {
                c.SetUIntegerAsInteger("mapId", _mapId);
                c.SetString("xpath", _xpath);
                c.SetOptionalBoolean("denormalized", _denormalized, false);
                c.SetEnum("xmlDataType", _xmlDataType);
                c.WriteOptionalElement (_extLst);
            }
        }

        #endregion
    }
}
